waitgroup
A WaitGroup waits for a collection of task to finish.
Examples
use WaitGroup;
use task;
async
License
This project is licensed under Apache License, Version 2.0 (LICENSE ).
A WaitGroup waits for a collection of task to finish.
use waitgroup::WaitGroup;
use async_std::task;
async {
let wg = WaitGroup::new();
for _ in 0..100 {
let w = wg.worker();
task::spawn(async move {
// do work
drop(w); // drop w means task finished
};
}
wg.wait().await;
}
This project is licensed under Apache License, Version 2.0 (LICENSE ).